﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Aliyeye.Car.Net.Utility
{
    public class SpeechWrapper: IDisposable
    {
        SpeechLib.SpVoice _spVoice = new SpeechLib.SpVoice();

        public SpeechWrapper()
        {
        }

        ~SpeechWrapper()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
        }

        public void Dispose(bool disposing)
        {
            Marshal.ReleaseComObject(_spVoice);

            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
        }

        public void Speak(string text)
        {
            _spVoice.Speak(text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
        }

        public void IncreaseRate()
        {
            this.IncreaseRate(1);
        }

        public void IncreaseRate(int rate)
        {
            _spVoice.Rate += rate;
        }
    }
}
